<template>
  <el-dialog
    title="新增测试数据"
    :close-on-click-modal="false"
    :visible.sync="visible">
    <el-form :model="dataForm" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">

      <el-form-item label="指标编码" prop="zbCode">
        <el-input type="input" v-model="dataForm.zbCode" placeholder="编码"></el-input>
      </el-form-item>
      <el-form-item label="指标名" prop="zbName">
        <el-input type="input" v-model="dataForm.zbName" placeholder="指标名"></el-input>
      </el-form-item>
      <el-form-item label="指标值" prop="zbValue">
        <el-input type="input" v-model="dataForm.zbValue" placeholder="指标值"></el-input>
      </el-form-item>
      <el-form-item label="监控指标" prop="zbLevel">
        <el-radio-group v-model="dataForm.dqState">
          <el-radio label="">是</el-radio>
          <el-radio label="norule">否</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="备注" prop="dqRemark">
        <el-input type="textarea" v-model="dataForm.dqRemark" placeholder="备注"></el-input>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
    </span>
  </el-dialog>
</template>

<script>
  import API from '@/api'
  export default {
    data () {
      return {
        visible: false,
        dataForm: {
          zbCode: '',
          zbName: '',
          zbValue: '',
          dqState: '',
          dqRemark: ''
        }
      }
    },
    methods: {
      init () {
        this.visible = true
      },
      dataFormSubmit () {
        var tick = API.zbconfig.addtest(this.dataForm)
        tick.then(({data}) => {
          if (data && data.code === 0) {
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {
                this.visible = false
                this.$emit('refreshDataList')
              }
            })
          } else {
            this.$message.error(data.msg)
          }
        })
      }
    }
  }
</script>

<style scoped>

</style>
